<?php namespace Common\Model;
use Hdphp\Model\Model;
//品牌管理模型
class Brand extends Model{
	protected $table="brand";
	protected $validate=array(
		array('bname','required','品牌名字不能为空',3,3),
	
	);
	protected $auto=array(
		array('blogo','thumb','method',3,3)
	);
	//自定义上传方法函数
	public function thumb(){
		if(isset($_FILES['blogo'])&& $_FILES['blogo']['error']!=4){
			$files=Upload::type('jpg,png,gif')->size(2000000)->make();
			//如果上传成功，返回对应路径
			if($files){
				return $files[0]['path'];
			}
		}
		if($blogo=Q('post.blogo'))
		return $blogo;
		return '';
	}
	public function store(){
		
		if(!$this->create()) return false;
		if($error=Upload::getError()){
			$this->error=$error;
			return false;
		}
		$this->add();
		return true;
	}
	public function edit(){
		if(!$this->create()) return false;
		if($error=Upload::getError()){
			$this->error=$error;
			return false;
		}
		$this->save();
		return true;
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
}





 ?>